﻿using System;

class CharacterStatistics
{
    static void Main(string[] args)
    {
        Console.WriteLine("字符统计程序");
        Console.WriteLine("============");
        Console.WriteLine("请输入一行字符：");

        string input = Console.ReadLine();

        if (string.IsNullOrEmpty(input))
        {
            Console.WriteLine("输入为空！");
            return;
        }

        var result = CountCharacters(input);

       
        DisplayResults(input, result);
    }

   
    static (int letters, int digits, int spaces, int others) CountCharacters(string input)
    {
        int letters = 0, digits = 0, spaces = 0, others = 0;

        foreach (char c in input)
        {
            if (char.IsLetter(c))
            {
                letters++;
            }
            else if (char.IsDigit(c))
            {
                digits++;
            }
            else if (char.IsWhiteSpace(c))
            {
                spaces++;
            }
            else
            {
                others++;
            }
        }

        return (letters, digits, spaces, others);
    }

 
    static void DisplayResults(string input, (int letters, int digits, int spaces, int others) result)
    {
        Console.WriteLine("\n 统计结果：");
        Console.WriteLine("================");
        Console.WriteLine($"输入字符串：\"{input}\"");
        Console.WriteLine($"总字符数：{input.Length}");
        Console.WriteLine($"英文字母：{result.letters} 个");
        Console.WriteLine($"数字：{result.digits} 个");
        Console.WriteLine($"空格：{result.spaces} 个");
        Console.WriteLine($"其他字符：{result.others} 个");

        
        if (input.Length > 0)
        {
            Console.WriteLine("\n 百分比：");
            Console.WriteLine($"字母：{result.letters * 100.0 / input.Length:F1}%");
            Console.WriteLine($"数字：{result.digits * 100.0 / input.Length:F1}%");
            Console.WriteLine($"空格：{result.spaces * 100.0 / input.Length:F1}%");
            Console.WriteLine($"其他：{result.others * 100.0 / input.Length:F1}%");
        }
    }
}